<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>客户支付表</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">客户名称</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" validate="{required:true}"
                               value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">客户ID</div>
                    <div class="field">
                        <input name="cstId" id="cstId" type="text" class="ui-textbox" validate="{number:true}"
                               value="">
                    </div>
                </div>
                <div class="formBtns notRight">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
    <div class="fieldset1 tabel_col tabel_col_s clearFix">
        <div class="sqPanel">
            <div class="sqPanel_head inL">
                <span>客户支付表</span>
            </div>
            <div class="sqPanel_body">
                <div id="paySchGrid" class="sq-grid"></div>
            </div>
        </div>
        <div class="sqPanel">
            <div class="sqPanel_head inL">
                <span>小贷</span>
            </div>
            <div class="sqPanel_body">
                <div id="mcrBillGrid" class="sq-grid"></div>
            </div>
        </div>
        <div class="sqPanel">
            <div class="sqPanel_head inL">
                <span>垫款</span>
            </div>
            <div class="sqPanel_body">
                <div id="advPayGrid" class="sq-grid"></div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    form = null, paySchGrid = null, mcrBillGrid = null, advPayGrid = null;
    $(function () {
        //客户支付表
        paySchGrid = $("#paySchGrid").ligerGrid({
            url: '<%=path%>/risk/rentRemind/initPaySchList.do',
            method: 'get',
            columns: [
                {display: '客户ID', name: 'cstId', minWidth: 100, align: 'left', enabledSort: false},
                {display: '客户名称', name: 'cstNm', minWidth: 100, align: 'left', enabledSort: false},
                {display: '支付表ID', name: 'id', width: 150, align: 'left', enabledSort: false},
                {display: '支付表号', name: 'paySchNo', Width: 160, align: 'left', enabledSort: false},
                {display: '项目ID', name: 'prjId', width: 150, align: 'left', enabledSort: false},
                {
                    display: '租赁物总价值', name: 'totLsItmAmt', width: 100, align: 'right',
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.totLsItmAmt / 100);
                    }
                },
                {display: '租赁期数', name: 'lsPd', width: 90, align: 'center', enabledSort: false,},
                {display: '起租日', name: 'lsDt', width: 100, align: 'center', enabledSort: false, render: renderDate},
                {display: '是否狮桥', name: 'isSqBiz', width: 100, align: 'center', enabledSort: false},
            ],
            usePager: false,
            delayLoad: true,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '300',
            heightDiff: -2,
            checkbox: false,
            rownumbers: false,
            allowUnSelectRow: true,
            alternatingRow: true,
            onBeforeShowData: function () {
                var grid = this;
                grid.collapsedRows = [];
            },
            detail: {
                height: 'auto',
                onShowDetail: showDetail_grid
            }
        });
        paySchGrid.setHeight(100);

        //小贷
        mcrBillGrid = $("#mcrBillGrid").ligerGrid({
            url: '<%=path%>/risk/rentRemind/initMcrBillList.do',
            method: 'get',
            columns: [
                {display: '客户ID', name: 'cstId', minWidth: 100, align: 'left', enabledSort: false},
                {display: '客户名称', name: 'cstNm', minWidth: 100, align: 'left', enabledSort: false},
                {
                    display: '贷款合同号', name: 'crCntNo', minWidth: 110, align: 'left',
                    render: function (rowdata, index, value) {
                        return '<a href="javascript:;" style="cursor: pointer;" onclick="billDtl(' + rowdata.id + ')">' + rowdata.crCntNo + '</a>';
                    }
                },
                {
                    display: '贷款金额', name: 'crAmtStr', minWidth: 80, align: 'right',
                    render: function (rowdata, index, value) {
                        if (rowdata.actCrAmt) {
                            return '&yen;' + rowdata.crAmtStr;
                        }
                    }
                },
                {
                    display: '实际放款金额', name: 'actCrAmtStr', minWidth: 80, align: 'right',
                    render: function (rowdata, index, value) {
                        if (rowdata.actCrAmtStr) {
                            return '&yen;' + rowdata.actCrAmtStr;
                        }
                    }
                },
                {display: '业务类型', name: 'loanBizTypCdNm', minWidth: 100, align: 'center', enabledSort: false},
                {display: '贷款类型', name: 'crTypCdNm', minWidth: 100, align: 'center', enabledSort: false},
                {
                    display: '租赁期数', name: 'crPd', minWidth: 80, align: 'center',
                    render: function (rowdata, index, value) {
                        return rowdata.crPd + rowdata.crPdUntCdNm;
                    }
                },
                {display: '放款日', name: 'crDtStr', minWidth: 100, align: 'center',},
                {display: '结清时间', name: 'stlDtStr', minWidth: 100, align: 'center',},
                {display: '贷款状态', name: 'loanStsCdNm', minWidth: 100, align: 'center', enabledSort: false},
                {
                    display: '创建日期',
                    name: 'crtTm',
                    minWidth: 100,
                    align: 'center',
                    enabledSort: false,
                    render: renderDate
                },
                {display: '机构名称', name: 'loanName', minWidth: 100, align: 'center', enabledSort: false},
                {
                    display: '是否回购', name: 'isInform', width: 150, enabledSort: true,
                    render: function (rowData) {
                        if (rowData.isInform == "1") {
                            return "是";
                        } else {
                            return "否";
                        }
                    }
                },
            ],
            usePager: false,
            delayLoad: true,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '300',
            heightDiff: -2,
            checkbox: false,
            rownumbers: false,
            allowUnSelectRow: true,
            alternatingRow: true,
            onBeforeShowData: function () {
                var grid = this;
                grid.collapsedRows = [];
            }
        });
        mcrBillGrid.setHeight(100);

        //垫款
        advPayGrid = $("#advPayGrid").ligerGrid({
            url: '<%=path%>/pbl/pblBillM/initList.do',
            <%--url: '<%=path%>/risk/rentRemind/initAdvPayList.do',--%>
            method: 'get',
            columns: [
                {display: '客户ID', name: 'cstId', minWidth: 100, align: 'left'},
                {
                    display: '客户名称', name: 'cstNm', minWidth: 100, align: 'left',
                    render: function (rowdata, rowindex, value) {
                        return '<a href="javascript:;" onclick="showCstDtl(' + rowdata.cstId + ')"><span class="gridTip" title="客户查看">' + rowdata.cstNm + '</span></a>';
                    }
                },
                {
                    display: '贷款合同号', name: 'crCntNo', minWidth: 110, align: 'left',
                    render: function (rowdata, index, value) {
                        return '<a href="javascript:;" style="cursor: pointer;" onclick="billDtl(' + rowdata.id + ')">' + rowdata.crCntNo + '</a>';
                    }
                },
                {display: '垫款单号', name: 'dzId', minWidth: 100, align: 'center', enabledSort: false},
                {
                    display: '贷款金额', name: 'contAmtStr', minWidth: 80, align: 'right',
                    render: function (rowdata, index, value) {
                        if (rowdata.contAmtStr) {
                            return '&yen;' + rowdata.contAmtStr;
                        }
                    }
                },
                {display: '业务类型', name: 'loanBizTypCdNm', minWidth: 100, align: 'center', enabledSort: false},
                {display: '贷款类型', name: 'crTypCdNm', minWidth: 100, align: 'center', enabledSort: false},
                {
                    display: '租赁期数', name: 'lsPd', minWidth: 80, align: 'center',
                    render: function (rowdata, index, value) {
                        return rowdata.lsPd + rowdata.lsPdUntCdNm;
                    }
                },
                {display: '放款日', name: 'lsDtStr', minWidth: 100, align: 'center',},
                {display: '结清时间', name: 'stlDtStr', minWidth: 100, align: 'center',},
                {display: '贷款状态', name: 'loanStsCdNm', minWidth: 100, align: 'center', enabledSort: false},
                {display: '支付表号', name: 'paySchNo', minWidth: 150, align: 'center', enabledSort: false},
                {
                    display: '创建日期',
                    name: 'crtTm',
                    minWidth: 100,
                    align: 'center',
                    enabledSort: false,
                    render: renderDate
                },
            ],
            usePager: false,
            delayLoad: true,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '250',
            heightDiff: -2,
            checkbox: false,
            rownumbers: false,
            allowUnSelectRow: true,
            alternatingRow: true,
            onBeforeShowData: function () {
                var grid = this;
                grid.collapsedRows = [];
            }
        });
        advPayGrid.setHeight(100);


        form = $("#searchBar").ligerForm({
            validate: true
        });
        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            if (!form.valid()) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                paySchGrid.setParm(name, data[name]);
                mcrBillGrid.setParm(name, data[name]);
                advPayGrid.setParm(name, data[name]);
            }
            paySchGrid.reload();
            mcrBillGrid.reload();
            advPayGrid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });


    });

    //逾期明细列表
    function showDetail_grid(row, detailPanel, callback) {
        var gridBox = document.createElement('div');
        $(gridBox).css('margin', 10);
        $(detailPanel).css({
            'padding': 10,
            'box-sizing': 'border-box'
        }).append(gridBox);
        detailGrid = $(gridBox).ligerGrid({
            url: '<%=path%>/risk/rentRemind/initPaySchDList.do?paySchId=' + row.id,
            method: 'get',
            columns: [
                {display: '费用类型', name: 'feeTypCdNm', width: 120, align: 'left'},
                {display: '期次', name: 'payPd', width: 90, align: 'center'},
                {display: '应收日期', name: 'payDt', width: 90, align: 'center', render: renderDate},
                {
                    display: '应收金额', name: 'feeAmt', width: 90, align: 'right', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.feeAmt / 100);
                    }
                },
                {
                    display: '已付金额', name: 'paidUpAmt', width: 100, align: 'right', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.paidUpAmt / 100);
                    }
                },
            ],
            root: 'rows',
            hideLoadButton: true,
            width: '100%',
            height: 'auto',
            isScroll: false,
            rownumbers: true,  //显示序号
            checkbox: false,
            allowUnSelectRow: true,
            alternatingRow: false,
            onAfterShowData: callback,
            frozen: false,
            usePager: false
        });
    }

    //查询客户详情
    function showCstDtl(_cstId) {
        Add_navTab("InsPlcCstBscInfo_" + _cstId, "客户信息", '<%=path%>/customer/cstbscinfo/toCustDetailPage.do?id=' + _cstId, null);
    }

    //查看账单详情
    function billDtl(billId) {
        Add_navTab('MCR_BILL_M_' + billId, '垫款贷账单详情', '<%=path%>/pbl/pblBillM/toPblBillDtlPage.do?id=' + billId);
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

</script>
</body>
</html>
